package geppetto.main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class CompareTableSourceAndTarget {
	public static void main(String[] args) throws IOException {
		String input = args[0];
		String input2 = args[1];
		String encoding = args[2];
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(input), encoding));
		BufferedReader reader2 = new BufferedReader(new InputStreamReader(new FileInputStream(input2), encoding));
		int n = 0;
		while(reader.ready() && reader2.ready()){			
			String line = reader.readLine();
			String line2 = reader2.readLine();
			String[] extract = line.split(" \\|\\|\\| ");
			String[] extract2 = line2.split(" \\|\\|\\| ");
			if(!extract[0].equals(extract2[0]) || !extract[1].equals(extract2[1])){
				System.err.println("Line " + n + ":");
				System.err.println("Table 1 - " + line);
				System.err.println("table 2 - " + line2);
			}
			n++;
		}
		if(reader.ready()){
			System.err.println("ERROR:table 1 is larger than table 2");
		}
		if(reader2.ready()){
			System.err.println("ERROR:table 2 is larger than table 1");			
		}
	}
}
